import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

//classify List type
export function listClassify(query) {
  // debugger
  return request({
    url: '/article/classify/list',
    method: 'get',
    params: query
  });
}
// 查询文章列表
export function listArticle(query) {
  return request({
    url: '/article/article/list',
    method: 'get',
    params: query
  })
}

// 新增文章
export function addArticle(data) {

  let content = data.content
  let tempContent = encodeURIComponent(content)
  let param = {
    ...data,
    content:tempContent,
  }
  return request({
    url: '/article/article',
    method: 'post',
    data: param
  })
}

export function getArticle(articleId) {
  return request({
    url: '/article/article/' + parseStrEmpty(articleId),
    method: 'get'
  })
}
// 删除文章
export function delArticle(articleId) {
  return request({
    url: '/article/article/' + articleId,
    method: 'delete'
  })
}
// 修改文章
export function updateArticle(data) {
  // debugger
  let content = data.content
  let tempContent = encodeURIComponent(content)
  let param = {
    ...data,
    content:tempContent,
  }
  return request({
    url: '/article/article',
    method: 'put',
    data: param
  })
}
